package com.canaan.business.service.storehouse;

import com.canaan.business.common.enums.inOutStock.InOutStockTypeEnum;
import com.canaan.business.common.enums.storehouse.InOutStorageOperationEnum;
import com.canaan.business.domain.agv.AgvTaskDispatch;
import com.canaan.business.domain.basic.WmsStorehouseLocation;
import com.canaan.business.domain.bo.InventoryOverviewBo;
import com.canaan.business.domain.storehouse.WmsStorehouseStock;
import com.canaan.business.domain.vo.InventoryOverviewVo;
import com.canaan.business.domain.vo.OutStockQueryVo;
import com.canaan.business.domain.vo.StorehouseStockAdjustDetailVo;
import com.canaan.business.domain.vo.WmsStorehouseStockVo;
import com.canaan.common.core.domain.AjaxResult;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 * 库存Service接口
 *
 * @author ruoyi
 * @date 2022-11-30
 */
public interface IWmsStorehouseStockService
{
    /**
     * 查询库存
     *
     * @param id 库存主键
     * @return 库存
     */
    public WmsStorehouseStock selectWmsStorehouseStockById(Long id);
    /**
     * 根据条码获取库存信息
     *
     * @param barcode 条码
     * @return 库存
     */
    public WmsStorehouseStock getInfoByBarcode(String barcode);
    /**
     * 根据条码获取盘点的库存条码信息
     *
     * @param barcode 条码
     * @return 库存
     */
    public WmsStorehouseStock  getCheckByBarcode(String barcode);
    /**
     * 根据条码获取库存信息列表
     *
     * @param barcodes 条码列表
     * @return 库存
     */
    public List<WmsStorehouseStock> getListByBarcodes(List<String> barcodes);

    /**
     * 根据质检任务号获取库存
     * @param qualityTaskNo
     * @return
     */
    public List<WmsStorehouseStock> getListByQualityTaskNo(String qualityTaskNo);
    /**
     * 根据库位获取库存信息
     *
     * @param locationNo 库位
     * @return 库存
     */
    public WmsStorehouseStock getInfoByLocationNo(String locationNo);
    /**
     * 根据库位获取库存信息列表
     *
     * @param locationNos 库位列表
     * @return 库存
     */
    public List<WmsStorehouseStock> getListByLocationNos(List<String> locationNos);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectWmsStorehouseStockList(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 页面查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    List<WmsStorehouseStock> selectNewWmsStorehouseStockListPageData(WmsStorehouseStock wmsStorehouseStock);
    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    List<WmsStorehouseStock> selectNewWmsStorehouseStockList(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 新增库存
     *
     * @param wmsStorehouseStock 库存
     * @return 结果
     */
    public int insertWmsStorehouseStock(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 批量新增库存
     *
     * @param storehouseStockList 库存列表
     * @return 结果
     */
    int batchInsertWmsStorehouseStock(List<WmsStorehouseStock> storehouseStockList);

    /**
     * 修改库存
     *
     * @param wmsStorehouseStock 库存
     * @return 结果
     */
    public int updateWmsStorehouseStock(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 批量修改库存
     *
     * @param storehouseStockList 库存列表
     * @return 结果
     */
    int batchUpdateWmsStorehouseStock(List<WmsStorehouseStock> storehouseStockList);

    /**
     * 批量删除库存
     *
     * @param ids 需要删除的库存主键集合
     * @return 结果
     */
    public int deleteWmsStorehouseStockByIds(Long[] ids);

    /**
     * 删除库存信息
     *
     * @param id 库存主键
     * @return 结果
     */
    public int deleteWmsStorehouseStockById(Long id);

    List<WmsStorehouseStock> selectWmsStorehouseStockListByProductNo(String productNo);

    List<WmsStorehouseStock>  selectWmsStorehouseStockListByLocationNo(String locationNo);

    WmsStorehouseStock selectWmsStorehouseStockByLocationNo(String locationNo);

    WmsStorehouseStock selectWmsStorehouseStockListByBarcode(String barcode);
    WmsStorehouseStock selectWmsStorehouseStockByTrayNo(String trayNo);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    List<WmsStorehouseStock> selectWmsStorehouseStockListByStorehouse(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 导入数据
     *
     * @param fileDataList 文件数据列表
     * @return 结果
     */
    String importData(List<WmsStorehouseStock> fileDataList);

    /**
     * 库存报警
     *
     */
    void inventoryAlert();

   List<WmsStorehouseStock> getStock(String storehouseNo,String productNo,String status,String areaNo,String whetherMp,String workOrderNo);
    /**
     * 查询库存总览
     * @param bo
     * @return
     */
    List<InventoryOverviewVo> selectInventoryOverview(InventoryOverviewBo bo);

    /**
     * 查询库存列表
     *
     * @param wmsStorehouseStock 库存
     * @return 库存集合
     */
    public List<WmsStorehouseStock> selectWmsStorehouseStockList2(WmsStorehouseStock wmsStorehouseStock);

    /**
     * 获取库存总数
     * @param storehouseNo
     * @param productNos
     * @return
     */
    List<InventoryOverviewVo> selectStockTotalQty(String storehouseNo,List<String> productNos);


    /**
     * 获取库存占用总数
     * @param storehouseNo
     * @param productNos
     * @return
     */
    List<InventoryOverviewVo> selectOccupyTotalQty(String storehouseNo,List<String> productNos);

    /**
     * 根据工单编号+物料编号查询备料区库存
     * @param whetherMp 是否备料区  Y是 N否
     * @param workOrderNo
     * @param productNo
     * @return
     */
    List<WmsStorehouseStock> selectMpByWorkOrderNoAndProductNo (String whetherMp, String workOrderNo,String productNo);


    /**
     * 根据条码将库存的容器更为空
     * @param barcode
     * @return
     */
    int updateContainerByBarcode( String barcode);

    /**
     * 绑定库位库存
     * @param location
     * @param shelfNo
     * @param trayNo
     * @param stockStatus
     * @param relBillNo
     * @param operation
     */
    void bindStorehouseStock(WmsStorehouseLocation location, String shelfNo, String trayNo,
                             String stockStatus, String relBillNo, InOutStockTypeEnum typeEnum, InOutStorageOperationEnum operation);

    /**
     * 查询线边仓出库空库位（按行列从小到大）
     * @return
     */
    List<WmsStorehouseStockVo> selectEmpWmsStorehouseOutStockList();
    /**
     * 处理AGV出库释放起点
     */
    void handleOutBinEvent(String location,AgvTaskDispatch taskDispatch);
    /**
     * 处理AGV完结事件
     */
    void handleAgvEndEvent(String source, String dest,AgvTaskDispatch taskDispatch);

    List<WmsStorehouseStockVo> selectWmsStorehouseStockListByProductNos(OutStockQueryVo outStockQueryVo);
    /**
     * 查询库存统计
     * @return
     */
    List<StorehouseStockAdjustDetailVo> selectWmsStorehouseStockAdjustList();
    /**
     * 根据物料查询库存的批次号
     * @param productNo 物料编号
     * @return
     */
    List<String> selectWmsStorehouseStockBatchNoByProductNo(String productNo);
    /**
     * 查询入库接驳空库位
     * @return
     */
    WmsStorehouseStockVo selectInDockingEmptyWmsStorehouseStock();
    /**
     * 查询出库接驳空料架
     * @return
     */
    WmsStorehouseStockVo selectOutDockingEmptyShelfStorehouseStock();
    /**
     * 查询成品库空料架
     * @return
     */
    List<WmsStorehouseStockVo> selectProductEmptyShelfStorehouseStock();

    /**
     * 绑定料架
     * @param vo
     * @return
     */
    String bindContainerNo(WmsStorehouseStockVo vo);

    /**
     * 解绑料架
     * @param vo
     * @return
     */
    AjaxResult unbindContainerNo(WmsStorehouseStockVo vo);

    /**
     * 解绑托盘
     * @param vo
     * @return
     */
    AjaxResult unbindTrayNo(WmsStorehouseStockVo vo);

    /**
     * 根据货架号查询对应信息
     *
     * @param containerNo
     * @return
     */
    WmsStorehouseStock selectStockInfosByContainerNo(String containerNo);
}
